package com.nutstudio.feitoys.utils;

import android.app.Activity;
import android.content.Context;
import android.util.DisplayMetrics;

/**
 * Created by Administrator on 2017/4/25 0025.
 */

public class UIUtils {
    public static int getDp(Context context, int old){
        return (int) (old*getScreenDensity(context));
    }
    public  static float getScreenDensity(Context activity){
        DisplayMetrics metric = new DisplayMetrics();
        ((Activity)activity).getWindowManager().getDefaultDisplay().getMetrics(metric);
        float density = metric.density;
        return density;
    }
}
